package com.example.speedeye;

import java.util.Random;

import android.support.v7.app.ActionBarActivity;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
import android.content.DialogInterface;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.SystemClock;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;

@SuppressLint("ClickableViewAccessibility")
public class MainActivity extends ActionBarActivity {

	LinearLayout myScreen;
	ImageView icon1, icon2, icon3;
	Button btDone, btExit, btRestart, btSound, btBonus;
	TextView text, scoreview;
	String nb = "";
	StringView arrayNumber[], arrayNumberBonus[];
	Random rd = new Random();
	int count = 0, countBonus = 0, progress = 100, timedown = 0, timedownBonus = 0;// nguoi choi co 3000ms de
													// nhap dap an
	int timeview = 100;
	int score = 0, heart = 3, scoreBonus=0;
	String isSoundString = "";//luu trang thai thiet lap cua nguoi dung ve am thanh o lan thiet lap cuoi
	
	boolean next = false, run = false, isSound=true, mySoundState;
	boolean isMenu = true, isBonus=false, isLevel;//isLevel = true khi nguoi choi vuot diem cua level truoc,
													//true de xac nhan rang nguoi choi co the an vao bonus khi trai tim chi con 1
												  //isBonus = true khi nguoi choi thao man dieu kien bonus. = false khi da chon bonus
	int level=1;
	ProgressBar pb;

	@Override
	protected void onCreate (Bundle savedInstanceState){
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_main);

//		if(savedInstanceState!=null){
//			myCurrentScore = savedInstanceState.getInt(scoreString);
//			mySoundState = savedInstanceState.getBoolean(isSoundString);
//			count = myCurrentScore;
//		} 
		
		myScreen = (LinearLayout)findViewById(R.id.myscreen);
		
		icon1 = (ImageView) findViewById(R.id.heart1);
		icon2 = (ImageView) findViewById(R.id.heart2);
		icon3 = (ImageView) findViewById(R.id.heart3);

		icon1.setImageResource(R.drawable.heart);
		icon2.setImageResource(R.drawable.heart);
		icon3.setImageResource(R.drawable.heart);

		pb = (ProgressBar) findViewById(R.id.progress);
		scoreview = (TextView) findViewById(R.id.scoreview);		
		
		btBonus = (Button)findViewById(R.id.bonus);
		btBonus.setOnClickListener(onBonus);

		btExit = (Button)findViewById(R.id.btexit);
		btRestart = (Button)findViewById(R.id.btrestart);
		
		btSound = (Button)findViewById(R.id.sound);
		btSound.setBackgroundResource(R.drawable.unmute);
		btSound.setOnClickListener(onSound);
		text = (TextView) findViewById(R.id.text);

		arrayNumber = new StringView[100];
		for (int i = 0; i < 100; i++) {
			arrayNumber[i] = new StringView();
		}

		arrayNumberBonus = new StringView[10];
		for(int i=0; i<10; i++){
			arrayNumberBonus[i] = new StringView();
		}
		
		buildNumber();

		btDone = (Button) findViewById(R.id.btdone);

		btDone.setOnClickListener(onDone2);
		
	}	
	private OnClickListener onSound = new OnClickListener() {
		
		@Override
		public void onClick(View arg0) {
			// TODO Auto-generated method stub
			if(isSound){
				btSound.setBackgroundResource(R.drawable.mute);
				isSound = false;
				//mute real sound
			} else {
				btSound.setBackgroundResource(R.drawable.unmute);
				isSound = true;
				//play sound
			}
		}
	};
	
	private AlertDialog setMyAlertDialog() {
		AlertDialog.Builder builder = new AlertDialog.Builder(this);
		builder.setTitle("Finish Game!");
		builder.setMessage("Your score: " + score + "\nRestart Game?");
		builder.setCancelable(false);

		// Tao nut RestartGame
		builder.setNeutralButton("Restart",
				new DialogInterface.OnClickListener() {

					@Override
					public void onClick(DialogInterface arg0, int arg1) {
						finish();
						startActivity(getIntent());
					}
				});

		// Tạo nút Thoát
		builder.setNegativeButton("Exit",
				new DialogInterface.OnClickListener() {
					public void onClick(DialogInterface dialog, int which) {
						finish();
					}
				});
		AlertDialog dialog = builder.create();
		return dialog;
	}

	private Runnable longTask = new Runnable() {
		
		int time = 0;
		

		@Override
		public void run() {
			// TODO Auto-generated method stub
			if(!isBonus) time =  timedown / 100;
			else time = timedownBonus/100;
			
			for (int i = 0; i < 100; i++) {
				if(run) {
					pb.setProgress(100);
					break;
				}
				pb.setProgress(progress);
				SystemClock.sleep(time);				
				progress--;				
			}
			
			Message msg = handler.obtainMessage();
			handler.sendMessage(msg);
		}
	};

	@SuppressLint("HandlerLeak")
	Handler handler = new Handler() {
		@Override
		public void handleMessage(Message msg) {
			
			if (progress == 0||progress==-1) {
				String txt="";
				txt = text.getText().toString();
				
				nb = "";
				progress = 100;
				pb.setProgress(progress);
				next = false;
				
				if(!isBonus){
					if(txt.equals(arrayNumber[count-1].s3) ||
							 txt.equals(arrayNumber[count-1].s1+arrayNumber[count-1].s2) ||
							 txt.equals(arrayNumber[count-1].s2+arrayNumber[count-1].s1) ){
							 text.setTextColor(Color.RED);
							 text.setText("good :)");
							 score++;
							 scoreview.setText(""+score);
							 scoreview.setTextColor(Color.RED);
						 } else {
							 text.setTextColor(Color.BLACK);
							 text.setText("bad :(");
							 checkGame();//ok
						 }
				} else {
					if(txt.equals(arrayNumberBonus[countBonus-1].s3) ||
							 txt.equals(arrayNumberBonus[countBonus-1].s1+arrayNumberBonus[countBonus-1].s2) ||
							 txt.equals(arrayNumberBonus[countBonus-1].s2+arrayNumberBonus[countBonus-1].s1) ){
							 text.setTextColor(Color.RED);
							 text.setText("Excellent!!");
							 scoreBonus++;
							 scoreview.setText(""+scoreBonus+"/5");
							 scoreview.setTextColor(Color.GREEN);
							 
							 if(scoreBonus==5){
								 isBonus = false;
								 isLevel = false;
								 final Handler handler1 = new Handler(Looper.getMainLooper());
									handler1.postDelayed(new Runnable() {
									            @Override
									            public void run() {
									                // Do something after time
									            	
									            	btBonus.setBackgroundResource(R.drawable.heartunbonus);
									            	text.setText("You WINNNNN!\nGain full heart");
									            	heart = 3;
									            	setFullHeart();
									            	handler1.postDelayed(new Runnable() {
											            @Override
											            public void run() {
											            	text.setText("SpeeDeye");
											            	text.setTextColor(Color.BLACK);
											            	scoreview.setTextColor(Color.RED);
											            	scoreview.setText(""+score);
											            }
											        },1000);
									            }
									        }, 1000);
							 }
						 } else {
							 text.setTextColor(Color.BLACK);
							 text.setText("Stupid :P");
							 isBonus = false;
							 isLevel = false;
							 
							 final Handler handler1 = new Handler(Looper.getMainLooper());
								handler1.postDelayed(new Runnable() {
								            @Override
								            public void run() {
								                // Do something after time
								            	btBonus.setBackgroundResource(R.drawable.heartunbonus);
								            	text.setText("You lose!\nBack to game");
//								            	
								            	handler1.postDelayed(new Runnable() {
										            @Override
										            public void run() {
										            	text.setText("SpeeDeye");
										            	text.setTextColor(Color.BLACK);
										            	scoreview.setText(""+score);
										            	scoreview.setTextColor(Color.RED);
										            }
										        },1000);
								            }
								        }, 1000);
							 //out game bonus
						 }
				}
				
			}
		}

	};	
	
	private OnClickListener onBonus = new OnClickListener() {
		
		@Override
		public void onClick(View v) {
			// TODO Auto-generated method stub
			if(heart==1 && isLevel) {
				isBonus = true;//chuyen sang phan bouns
				
				btBonus.setBackgroundResource(R.drawable.heartbonuschoose);
				text.setTextColor(Color.RED);
				text.setText("Gaining heart!\nREADY?");
				
				scoreview.setTextColor(Color.BLACK);
				scoreview.setText("error is dead");
				
				buildNumberBonus();
			}
		}
	};
	
	private OnClickListener onDone2 = new OnClickListener() {

		@Override
		public void onClick(View arg0) {
			// TODO Auto-generated method stub
			if(!isBonus){
				
				if (!next) {
					
					run = false;
					
					if(count%3 == 0) text.setTextColor(Color.RED);
					else if(count%5 == 0) text.setTextColor(Color.BLACK);
					else text.setTextColor(Color.DKGRAY);
									
					text.setText(arrayNumber[count].s3);
					count++;
					checkScore();
					checkBonus();
					checkTime();
		            
					final Handler handler1 = new Handler(Looper.getMainLooper());
					handler1.postDelayed(new Runnable() {
					            @Override
					            public void run() {
					                // Do something after 3s = 3000ms
					            	text.setText("Enter\nyour number");
					            	
					            	try{
					            		Thread th = new Thread(longTask);
					            		th.start();
					            	} catch(Exception e){
					            		e.printStackTrace();
					            	}
					            	
					            }
					        }, timeview);
					next = true;
				}
				else {
					 //kiem tra xem nguoi choi nhap dung k?
					run = true;
					progress=100;
					pb.setProgress(100);
					
					 String txt="";
					 txt = text.getText().toString();
					
					 if(txt.equals(arrayNumber[count-1].s3) ||
						 txt.equals(arrayNumber[count-1].s1+arrayNumber[count-1].s2) ||
						 txt.equals(arrayNumber[count-1].s2+arrayNumber[count-1].s1) ){
						 text.setTextColor(Color.RED);
						 text.setText("good :)");
						 score++;
						 scoreview.setText(""+score);
						 scoreview.setTextColor(Color.RED);		
						 
					 } else {
						 text.setTextColor(Color.BLACK);
						 text.setText("bad :(");
						 checkGame();//ok
						 
//						 checkBonus();
						 
					 }				
					 nb = "";				 
					 next = false;				
				}
			}
			
				
			else {//vao phan bonus day nguy hiem// co bo sung them viec thay doi hinh nen ma quy va am thanh rung ron cho level 3, 4
				if (!next) {
					
					run = false;
					
					if(countBonus%3 == 0) text.setTextColor(Color.BLUE);
					else if(countBonus%5 == 0) text.setTextColor(Color.BLACK);
					else text.setTextColor(Color.DKGRAY);
									
					text.setText(arrayNumberBonus[countBonus].s3);
					countBonus++;
					
//					if(countBonus==3 && level==1) myScreen.setBackgroundResource(R.drawable.evil);
					//phat trien phan rung ron trong game bonus
		            
					final Handler handler1 = new Handler(Looper.getMainLooper());
					handler1.postDelayed(new Runnable() {
					            @Override
					            public void run() {
					                // Do something after 3s = 3000ms
					            	text.setText("Your number");
//					            	myScreen.setBackgroundResource(R.drawable.background);
					            	
					            	try{
					            		Thread th = new Thread(longTask);
					            		th.start();
//					            		myScreen.setBackgroundResource(R.drawable.evil);
					            	} catch(Exception e){
					            		e.printStackTrace();
					            	}
					            	
					            }
					        }, timeview);
					next = true;
				}
				else {
					 //kiem tra xem nguoi choi nhap dung k?
					run = true;
					progress=100;
					pb.setProgress(100);
					
					 String txt="";
					 txt = text.getText().toString();
					
					 if(txt.equals(arrayNumberBonus[countBonus-1].s3) ||
						 txt.equals(arrayNumberBonus[countBonus-1].s1+arrayNumberBonus[countBonus-1].s2) ||
						 txt.equals(arrayNumberBonus[countBonus-1].s2+arrayNumberBonus[countBonus-1].s1) ){
						 
						 text.setText("Excellent!!!");
						 text.setTextColor(Color.GREEN);
						 scoreBonus++;
						 scoreview.setText(""+scoreBonus+"/5");
						 scoreview.setTextColor(Color.BLACK);
						 
						 if(scoreBonus==5){
							 isBonus = false;
							 isLevel = false;
							 final Handler handler1 = new Handler(Looper.getMainLooper());
								handler1.postDelayed(new Runnable() {
								            @Override
								            public void run() {
								                // Do something after time
								            	btBonus.setBackgroundResource(R.drawable.heartunbonus);
								            	text.setText("You WINNNNN!\nGain full heart");
								            	heart = 3;
								            	setFullHeart();
								            	handler1.postDelayed(new Runnable() {
										            @Override
										            public void run() {
										            	text.setText("SpeeDeye");
										            	text.setTextColor(Color.BLACK);
										            	scoreview.setText(""+score);
										            	scoreview.setTextColor(Color.RED);
										            }
										        },1000);
								            }
								        }, 1000);
						 }
						 
					 } else {
						 text.setTextColor(Color.BLACK);
						 text.setText("Stupid :P");
						 isBonus = false;
						 isLevel = false;
						 
						 final Handler handler1 = new Handler(Looper.getMainLooper());
							handler1.postDelayed(new Runnable() {
							            @Override
							            public void run() {
							                // Do something after time
							            	btBonus.setBackgroundResource(R.drawable.heartunbonus);
							            	text.setText("You lose!\nBack to game");
//							            	
							            	handler1.postDelayed(new Runnable() {
									            @Override
									            public void run() {
									            	text.setText("SpeeDeye");
									            	text.setTextColor(Color.BLACK);
									            	scoreview.setText(""+score);
									            	scoreview.setTextColor(Color.RED);
									            }
									        },1000);
							            }
							        }, 1000);
						 //out game bonus
					 }				
					 nb = "";				 
					 next = false;				
				}
			}
		}
	};
	
	public void checkTime(){
		if (level == 1) {
			timedown = 2000;
			timedownBonus = 1500;
		}
		else if(level == 2) {
			timedownBonus = 2000;
			timedown = 2500;
		} else if(level == 3) {
			timedown = 3200;
			timedownBonus = 30000;
		} else {
			timedown = 4000;
			timedownBonus = 3500;
		}
	}
	
	public void checkBonus(){
		
		if(heart==1 && isLevel){
			btBonus.setBackgroundResource(R.drawable.heartbonus);
		}
	}
	
	public void checkScore(){
		if(count == 1){
			isLevel = true;
			level = 1;
		} else if(count == 20){
			isLevel = true;
			level = 2;
		} else if(count == 50){
			isLevel = true;
			level = 3;
		}
	}
	
	//Tao lap lai toan bo trai tim cho nguoi choi khi chien thang
	public void setFullHeart(){
		icon2.setImageResource(R.drawable.heart);
		icon1.setImageResource(R.drawable.heart);
	}
	
	// Kiem tra cac dieu kien khi nguoi choi het thoi gian hoac tra loi sai
	public void checkGame() {
		heart--;
		if (heart == 0){			
			icon3.setImageResource(R.drawable.heartempty);
			AlertDialog myAlertDialog = setMyAlertDialog();
			myAlertDialog.show();
		}
		else if (heart == 1){
			if(isLevel) btBonus.setBackgroundResource(R.drawable.heartbonus);
			icon2.setImageResource(R.drawable.heartempty);
		}			
		else if (heart == 2)
			icon1.setImageResource(R.drawable.heartempty);
	}

	//Khoi tao ngau nhien gia tri cho mang arrayNumberBonus
	public void buildNumberBonus(){
		if(count>=1 && count<20){
			arrayNumberBonus[0].s3 = randomInt(2);
			arrayNumberBonus[1].s3 = randomInt(2);
			arrayNumberBonus[2].s3 = randomInt(3);
			arrayNumberBonus[3].setString(randomInt(2), randomInt(2), 1);
			arrayNumberBonus[4].s3 = randomInt(4);
		} else if(count>=20 && count<50){
			arrayNumberBonus[0].s3 = randomInt(4);
			arrayNumberBonus[1].setString(randomInt(1), randomInt(3), 3);
			arrayNumberBonus[2].setString(randomInt(2), randomInt(2), 2);
			arrayNumberBonus[3].setString(randomInt(2), randomInt(2), 1);
			arrayNumberBonus[4].setString(randomInt(2), randomInt(2), 1);
		} else if(count>=50 && count<75){
			arrayNumberBonus[0].s3 = randomInt(5);
			arrayNumberBonus[1].setString(randomInt(3), randomInt(2), 2);
			arrayNumberBonus[2].setString(randomInt(2), randomInt(2), 3);
			arrayNumberBonus[3].setString(randomInt(2), randomInt(3), 1);
			arrayNumberBonus[4].setString(randomInt(3), randomInt(3), 1);
		}
	}
	
	// khoi tao ngau nhien gia tri cho mang arrayNumber
	public void buildNumber() {

		for (int i = 0; i < 8; i++) {
			arrayNumber[i].s3 = randomInt(2);
		}
		for (int i = 8; i < 10; i++) {
			arrayNumber[i].setString(randomInt(1), randomInt(1), 1);// option =
																	// 1 la dong
																	// thang
		}
		for (int i = 10; i < 15; i++) {
			arrayNumber[i].s3 = randomInt(3);
		}
		for (int i = 15; i < 17; i++) {
			arrayNumber[i].setString(randomInt(1), randomInt(2), 1);// option =
																	// 1 la dong
																	// thang
		}
		for (int i = 17; i < 20; i++) {
			arrayNumber[i].setString(randomInt(2), randomInt(2), 1);
		}
		for (int i = 20; i < 26; i++) {
			arrayNumber[i].s3 = randomInt(4);
		}
		for (int i = 26; i < 28; i++) {
			arrayNumber[i].setString(randomInt(2), randomInt(2), 1);
		}
		for (int i = 28; i < 30; i++) {
			arrayNumber[i].setString(randomInt(2), randomInt(2), 2);
		}
		for (int i = 30; i < 35; i++) {
			arrayNumber[i].s3 = randomInt(4);
		}
		for (int i = 35; i < 38; i++) {
			arrayNumber[i].setString(randomInt(1), randomInt(3), 1);
		}

		arrayNumber[38].setString(randomInt(1), randomInt(3), 2);
		arrayNumber[38].setString(randomInt(1), randomInt(3), 3);

		for (int i = 40; i < 46; i++) {
			arrayNumber[i].setString(randomInt(2), randomInt(2), 1);
		}
		for (int i = 46; i < 48; i++) {
			arrayNumber[i].setString(randomInt(2), randomInt(2), 2);
		}
		for (int i = 48; i < 50; i++) {
			arrayNumber[i].setString(randomInt(2), randomInt(2), 3);
		}
		for (int i = 50; i < 57; i++) {
			arrayNumber[i].s3 = randomInt(5);
		}
		for (int i = 57; i < 64; i++) {
			arrayNumber[i].setString(randomInt(3), randomInt(2), 1);
		}
		for (int i = 64; i < 70; i++) {
			arrayNumber[i].setString(randomInt(2), randomInt(3), 1);
		}
		arrayNumber[70].s3 = randomInt(5);
		arrayNumber[71].setString(randomInt(3), randomInt(2), 1);
		arrayNumber[72].setString(randomInt(3), randomInt(2), 2);
		arrayNumber[73].setString(randomInt(3), randomInt(2), 3);
		arrayNumber[74].setString(randomInt(2), randomInt(3), 1);

		for (int i = 75; i < 82; i++) {
			arrayNumber[i].setString(randomInt(3), randomInt(3), 1);
		}
		for (int i = 82; i < 89; i++) {
			arrayNumber[i].s3 = randomInt(6);
		}
		for (int i = 89; i < 95; i++) {
			arrayNumber[i].s3 = randomInt(7);
		}
		for (int i = 95; i < 100; i++) {
			arrayNumber[i].s3 = randomInt(8);
		}
	}

	public String randomInt(int option) {// option la so luong chu so

		if (option == 1)
			return Integer.toString(rd.nextInt(9));
		else if (option == 2)
			return Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9));
		else if (option == 3)
			return Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9));
		else if (option == 4)
			return Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9));
		else if (option == 5)
			return Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9));
		else if (option == 6)
			return Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9));
		else if (option == 7)
			return Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9));
		else if (option == 8)
			return Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9))
					+ Integer.toString(rd.nextInt(9));
		else
			return "0";
	}
	
	public void btMenu(View v){
		if(isMenu){
			btExit.setVisibility(View.VISIBLE);
			btRestart.setVisibility(View.VISIBLE);
			isMenu = false;
		} else {
			btExit.setVisibility(View.GONE);
			btRestart.setVisibility(View.GONE);	
			isMenu = true;
		}
		
	}
	
	public void btExit(View v){
		if(!isMenu){
			isMenu = true;
			finish();
		}
	}
	
	public void btRestart(View v){
		if(!isMenu){
			isMenu = true;
			finish();
			startActivity(getIntent());
		}
	}
	
	public void btDelete(View v){
		if(next){
			nb = nb.substring(0, nb.length()-1);
			text.setText(nb);
		}		
	}
	
	public void bt0(View v) {
		if (next) {
			nb += "0";
			text.setText(nb);
		}
	}

	public void bt1(View v) {
		if (next) {
			nb += "1";
			text.setText(nb);
		}

	}

	public void bt2(View v) {
		if (next) {
			nb += "2";
			text.setText(nb);
		}

	}

	public void bt3(View v) {
		if (next) {
			nb += "3";
			text.setText(nb);
		}

	}

	public void bt4(View v) {
		if (next) {
			nb += "4";
			text.setText(nb);
		}

	}

	public void bt5(View v) {
		if (next) {
			nb += "5";
			text.setText(nb);
		}

	}

	public void bt6(View v) {
		if (next) {
			nb += "6";
			text.setText(nb);
		}

	}

	public void bt7(View v) {
		if (next) {
			nb += "7";
			text.setText(nb);
		}

	}

	public void bt8(View v) {
		if (next) {
			nb += "8";
			text.setText(nb);
		}

	}

	public void bt9(View v) {
		if (next) {
			nb += "9";
			text.setText(nb);
		}

	}

	@Override
	protected void onStart() {
		super.onStart();
		// The activity is about to become visible.
	}
	
	@Override
	protected void onResume() {
		super.onResume();
		// The activity has become visible (it is now "resumed").
	}
	
	@Override
	protected void onPause() {
		super.onPause();
		// Another activity is taking focus (this activity is about to be "paused").
	}
	
	@Override
	protected void onStop() {
		super.onStop();
		// The activity is no longer visible (it is now "stopped")
	}
	
	@Override
	protected void onDestroy() {
		super.onDestroy();
		// The activity is about to be destroyed.
	}
	
}

class StringView {
	String s1 = "", s2 = "", s3 = "";

	public void setString(String s1, String s2, int option) {
		// option la cac dang hien thi cua s1 va s2 se luu trong s3
		this.s1 = s1;
		this.s2 = s2;
		if (option == 1) {// dang 2 dong thang
			this.s3 = s1 + "\n" + s2;
		} else if (option == 2) {// dang 2 dong cheo tren
			this.s3 = s1 + "\n   " + s2;// co the phat trien sau nay de tang
										// khoang cach cua s1 & s2
		} else if (option == 3) {// dang 2 dong cheo duoi
			this.s3 = s1 + "   \n" + s2;
		}
	}
}
